﻿using GarageManagement.Data.Context;

namespace GarageManagement.Data.Infrastructure
{
    public class DatabaseFactory : Disposable, IDatabaseFactory
    {
        private GarageManagementContext dataContext;

        public GarageManagementContext Get()
        {
            return dataContext ?? (dataContext = new GarageManagementContext());
        }

        protected override void DisposeCore()
        {
            if (dataContext != null)
                dataContext.Dispose();
        }
    }
}
